import os
from tqdm import tqdm
import xml.etree.ElementTree as ET

# Set annotation-input path
annotation_input_path = 'F:\\items\\bike-model\\搜集的数据集\\解压后\\archive(1)\\dataset\\zzxa'

# Set annotation-output path
annotation_output_path = 'F:\\items\\bike-model\\搜集的数据集\\解压后\\archive(1)\\dataset\\zzxa2'

for filename in tqdm(os.listdir(annotation_input_path)):
    # Load the VOC XML file
    tree = ET.parse(os.path.join(annotation_input_path, filename))
    root = tree.getroot()

    # Rename the annotation object name
    for obj in root.findall('object'):
        if obj.find('name').text == 'Bicycle':
            obj.find('name').text = 'private_bike'

    # Save the updated VOC XML file
    tree.write(os.path.join(annotation_output_path, filename))
